package com.zh.zhbootcommon.entity.user;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zh.zhbootcommon.domain.DBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 角色信息表
 * </p>
 *
 * @author JueDream
 * @since 2021-08-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("zh_role")
@ApiModel(value="ZhRole对象", description="角色信息表")
public class Role extends DBaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "角色编号")
    @TableId(value = "role_id", type = IdType.AUTO)
    private Integer roleId;

    @ApiModelProperty(value = "角色名称")
    @TableField("role_name")
    private String roleName;

    @ApiModelProperty(value = "角色备注")
    @TableField("role_remark")
    private String roleRemark;

    @ApiModelProperty(value = "用户权限")
    @TableField(exist = false)
    private List<Permission> permissions = new ArrayList<>();

    public Role(){}

    @Builder
    public Role(Integer roleId, String roleName, String roleRemark, List<Permission> permissions) {
        this.roleId = roleId;
        this.roleName = roleName;
        this.roleRemark = roleRemark;
        this.permissions = permissions;
    }
}
